library(lavaan)

##Prepare data with sufficient statisitics##
mymeans<-matrix(c(3.06893, 2.92590, 3.11013), ncol=3,nrow=1)
mysd<-c(0.84194,0.88934,0.83470)
mat <- c(1.00000,
         0.55226, 1.00000,
         0.56256, 0.66307, 1.00000)
mycor <- getCov(mat, lower = TRUE)
##Transform correlation matrix to covariance matrix using information above##
myvarcov <- outer(mysd, mysd, FUN="*")
mycov <- mycor * myvarcov

rownames(mycor) <-c( "Glad", "Cheerful", "Happy")
colnames(mycor) <-c( "Glad", "Cheerful", "Happy")

rownames(mycov) <-c( "Glad", "Cheerful", "Happy")
colnames(mycov) <-c( "Glad", "Cheerful", "Happy")
mynob<-823
Descriptive Statistics
  Glad Cheerful Happy
Glad 1.00 0.55 0.56
Cheerful 0.55 1.00 0.66
Happy 0.56 0.66 1.00
Mean 3.07 2.93 3.11
SD 0.84 0.89 0.83
Var 0.71 0.79 0.70

Fundamental SEM equation

\[ \Sigma = \Lambda \Psi \Lambda + \Theta \tag{1} \]

Latent Cheer with one indicator

# Mplus file
l.cheer.inp

Measurement Model: 3 indicators

using correlations only (instead of variance/covariance matirx)

Found more than one class "Model" in cache; using the first, from namespace 'MatrixModels'
lavaan (0.5-20) converged normally after   9 iterations

  Number of observations                           823

  Estimator                                         ML
  Minimum Function Test Statistic                0.000
  Degrees of freedom                                 0

Model test baseline model:

  Minimum Function Test Statistic                0.000
  Degrees of freedom                                 0
  P-value                                           NA

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.000

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -1070.768
  Loglikelihood unrestricted model (H1)      -1070.768

  Number of free parameters                          1
  Akaike (AIC)                                2143.536
  Bayesian (BIC)                              2148.249
  Sample-size adjusted Bayesian (BIC)         2145.074

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent Confidence Interval          0.000  0.000
  P-value RMSEA <= 0.05                          1.000

Standardized Root Mean Square Residual:

  SRMR                                           0.000

Parameter Estimates:

  Information                                 Expected
  Standard Errors                             Standard

Latent Variables:
                   Estimate  Std.Err  Z-value  P(>|z|)
  Positive =~                                         
    Cheerful          1.000                           

Variances:
                   Estimate  Std.Err  Z-value  P(>|z|)
    Positive          0.790    0.039   20.285    0.000
    Cheerful          0.000                           
cat(file = 'topics/2_MeasurementModel/2b_ConfirmatoryFactorAnalysis/mplus/l.cheer.out')